<template>
	<view>
		<view class="submit">
			<view class="submit-chat">
				<view class="bt-img">
					<image :src="toc" @click="records"></image>
				</view>
				<textarea id="shuru" auto-height="true" class="chat-send btn" :class="{displaynone:isrecord}"
					@input="inputs" v-model="msg"></textarea>
				<view class="record btn" :class="{displaynone:!isrecord}">按住说话</view>
				<view class="bt-img" @click="add">
					<image src="../../static/tianjia.png"></image>
				</view>
				<view class="bt-img">
					<image src="../../static/biaoqing.png"></image>
				</view>
				<view class="enter" @click="enter">发送</view>
			</view>
			<view class="add" :class="{displaynone: isadd}">
				<view class="xxk">
					<view class="neir">请选择您要咨询的内容</view>
					<view class="xxk-">
						<view :class="['inv-h',Inv==0?'inv-h-se':'']" @click="Inv=0">我的订单</view>
						<view :class="['inv-h',Inv==1?'inv-h-se':'']" @click="Inv=1">我的浏览</view>
						<view :class="['inv-h',Inv==2?'inv-h-se':'']" @click="Inv=2">我的关注</view>
						<view :class="['inv-h',Inv==3?'inv-h-se':'']" @click="Inv=3">购物车</view>
					</view>
				</view>
				<view class="xxk-x" >
					<scroll-view v-show="Inv == 0" scroll-y="true" class="nimasile">
						<view class="search">
							<input class="search-shuru" placeholder="搜索关键词"  placeholder-class="pla" />
						</view>
						<dingdan @enterorder="enterorder" v-model="etr"></dingdan>
					</scroll-view>
					<view v-show="Inv == 1">区分</view>
					<view v-show="Inv == 2"><dingdan @enterorder="enterorder" v-model="etr"></dingdan></view>
					<scroll-view class="nimasile" v-show="Inv == 3" scroll-y="true"><dingdan @enterorder="enterorder" v-model="etr"></dingdan></scroll-view>
				</view>
				<!-- <view class="add-cd">
					<view class="add-cd_" @click="fasongdd">
						<view class="fsdd">
							<image class="fsdd-dd" mode="aspectFill" src="../../static/dingdan.png"></image>
						</view>
						<view class="fsdd-d">发送订单</view>
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import dingdan from '../../components/dingdan/dingdan.vue'
	export default {
		components: {
			dingdan,
		},
		data() {
			return {
				etr: "",
				msg: "",
				isrecord: false,
				toc: "../../static/yyimg.png",
				isadd: true,
				Inv: 0,
			}
		},
		methods: {
			//发送订单
			enterorder: function(e) {
				this.$emit('enterorder', this.etr);
				setTimeout(() => {
					this.etr = '';
				}, 0);
				console.log(e);
			},


			//获取模块高度
			getElementHeight: function() {
				const query = uni.createSelectorQuery().in(this);
				query.select('.submit').boundingClientRect(data => {
					this.$emit('heights', data.height);
				}).exec();
			},
			//点击切换音频
			records: function() {
				if (this.isrecord) {
					this.isrecord = false;
					this.toc = "../../static/yyimg.png";
				} else {
					this.isrecord = true;
					this.toc = "../../static/jianpan.png";
				}
			},
			add: function() {
				this.isadd = !this.isadd;
				setTimeout(() => {
					this.getElementHeight();
				}, 0)

			},

			//文字发送
			enter: function(e) {
				this.$emit('inputs', this.msg);
				setTimeout(() => {
					this.msg = '';
				}, 0);
			},
			inputs: function(e) {
				// var x = document.getElementById("shuru");
				var chatm = e.detail.value;
				var pos = chatm.indexOf('\n');
				if (pos != -1 && chatm.length > 1) {
					console.log(this.msg)
					this.$emit('inputs', this.msg);
					setTimeout(() => {
						this.msg = '';
					}, 0);

				}

			}

		}
	}
</script>

<style lang="scss">
	.nimasile{
		height: 500rpx;
	}
	.submit {
		background-color: #f4f4f4;
		// background: rqba(244,244,244,0.96);
		border-top: 1px solid $uni-border-color;
		width: 100%;
		
		position: fixed;
		bottom: 0;
		z-index: 100;
		padding-bottom: var(--status-bar-height);

	}

	.submit-chat {

		width: 100%;


		display: flex;
		align-items: center;
		box-sizing: border-box;
		padding: 14rpx 14rpx;

		.enter {
			font-size: 20rpx;
			flex: none;
			padding: 0 10rpx;
		}

		image {
			width: 56rpx;
			height: 56rpx;
			margin: 0 10rpx;
			flex: auto;
		}

		.btn {

			flex: auto;
			background-color: #fff;
			border-radius: 10rpx;
			padding: 20rpx;
			max-height: 160rpx;
			margin: 0 10rpx;

		}

		.record {
			color: #757575;
			text-align: center;
			font-size: auto;

			flex: auto;
			background-color: #fff;
			border-radius: 10rpx;
			padding: 20rpx;

			margin: 0 10rpx;
		}


	}

	.displaynone {
		display: none;
	}

	.add {
		width: 100%;
		height: 600rpx;
		background: rqba(236, 237, 238, 1);
		box-shadow: 0px -1rpx 0px 0px rgba(0, 0, 0, 0.1);
		.xxk-x{
			width: 100%;
			height: 100%;
			background-color: #FFF;
			.search{
				width: 100%;
				height:50rpx;
				display: flex;
				justify-content: center;
				padding-top: 15rpx;
				margin-bottom: 10rpx;
				.pla{
					font-size: 32rpx;
					color: #babfc6;
					padding-left: 20rpx;
				}
				.search-shuru{
					height: 100%;
					width: 92%;
					border:3rpx solid #000000 ;
					background-color:#f7f7f7 ;
					border-radius: 50rpx;
					font-size: 32rpx;
					padding-left: 20rpx;
				}
			}
		}
		.xxk {
			display: flex;
			flex-direction: column;

			.neir {
				font-size: 26rpx;
				font-weight: 600;
				padding: 10rpx;
			}

			.xxk- {
				background-color: #f5f5f5;
				width: 100%;
				height: 50rpx;
				align-items: center;
				display: flex;
				justify-content: space-around;
				font-size: 26rpx;
				font-weight: 600;
				border: 3rpx solid #cecece;
				// .inv-h-w{background-color: #FFFFFF;height: 100upx;display: flex;}
				
				// .inv-h{font-size: 30upx;color: #C9C9C9;height: 100upx;}
				
				.inv-h-se{color: #5BA7FF;border-bottom: 4upx solid #5BA7FF;}
			}
		}

		.add-cd {
			padding: 50rpx;
			width: 100%;
			height: 100%;

			.fsdd-d {
				font-size: 20rpx;
				padding-top: 10rpx;
			}

			.fsdd {
				background-color: #fff;
				display: flex;
				align-items: center;
				justify-content: center;
				width: 100rpx;
				height: 100rpx;
				border-radius: 10rpx;


				.fsdd-dd {
					width: 56rpx;
					height: 56rpx;
				}
			}
		}

	}
</style>
